package edu.uoc.tdp.pac4.client.stats;

import java.rmi.RemoteException;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;

import edu.uoc.tdp.pac4.beans.Course;
import edu.uoc.tdp.pac4.client.ClientConnectionHelper;
import edu.uoc.tdp.pac4.common.util.LanguageUtils;


public class StatsHelper {

	
	public static DefaultComboBoxModel fillCourses(ClientConnectionHelper connectionHelper_) {
		List<Course> cursos = null;
		try {
			cursos = connectionHelper_.getStatsManager().loadAllCourses();
		} catch (RemoteException e) {
			JOptionPane.showMessageDialog(null, LanguageUtils
					.getMessage("client.error.message.remote"),
					LanguageUtils.getMessage("client.error.title"),
					JOptionPane.ERROR_MESSAGE);
		}
		DefaultComboBoxModel model = new DefaultComboBoxModel();
		model.addElement(null);
		for (int i = 0; i < cursos.size(); i++) {
			model.addElement(cursos.get(i).getCourseName());
		}
		return model;

	}
	
}
